<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加部门</title>
    <link type="text/css" rel="stylesheet" href="/css/index.css"/>
    <script type="text/javascript" src="/js/vue.js"></script>
    <script type="text/javascript" src="/js/index.js"></script>
    <script type="text/javascript" src="/js/axios.min.js"></script>
    <script type="text/javascript" src="/js/qs.min.js"></script>
</head>
<body>
<div id="app">
    <el-form  :model="section" label-width="80px">
<!--        <div style="width: 600px">-->
            <el-form-item label="部门名称">
            <el-input v-model="section.name" placeholder="请输入内容"></el-input>
            </el-form-item>
<!--        </div>-->

        <div class="block">
            <el-form-item label="创建日期">
            <el-date-picker
                    v-model="section.createTime"
                    align="right"
                    type="date"
                    placeholder="选择日期"
                    :picker-options="pickerOptions">
            </el-date-picker>
            </el-form-item>
        </div>
    </el-form>
    <div style="margin: 10px 10px 10px 10px">
        <el-button type="primary" @click="addDept">添加部门</el-button>
    </div>
</div>
</body>
<script>
    var app= new Vue({
        el:"#app",
        data:{
            section:{},
            timer: null,
        },
        methods:{
            //添加部门
            addDept(){
                axios.post("/dept/insert",this.section).then(resp=>{
                    if(resp.data.code == 200){
                        this.$message.success("添加成功");
                        clearTimeout(this.timer); //清除延迟执行

                        this.timer = setTimeout(()=>{  //设置延迟执行
                            this.update();
                        },1000);
                    }else {
                        this.$message.success("添加失败")
                    }
                })
            },

            //跳转
            update(){
                window.parent.iframeFunction('/selectIdDept.html','查看部门');
            },
        }
    })
</script>
</html>